<?php


namespace app\general\controller;


use think\Controller;
use think\Db;

class Play extends Controller
{
    //代理商id
    const PID="023c003b28fe4ceba8163e47388217bd";
    //域名
    const BASEURL="http://smms.sbdznkj.com:2018/SbdVoip/";
    /**
     * 随便打注册
     */
    public function reg(){
        $pn=15;
        $user_list=Db::table("xys_sq_jinzhu")->field("mobile")->limit(($pn-1)*60,60)->select();
        foreach ($user_list as $u){
            if(!empty($u['mobile'])){
                echo $u['mobile']."</br>";
                $data=array(
                    "Mobile"=>$u['mobile'],
                    "ParentId"=>self::PID,
                    "Password"=>"123456"
                );
                $token=$this->curl_post(self::BASEURL."login/register",$data);
                var_dump($token);
            }
        }
    }
    /**
     * 更新密码
     */
    public function modifyPassword(){
        $data=array(
            "Theme"=>"654321",
            //"ParentId"=>self::PID,
        );
        $header="921B80AF6B5E5F63FD45B970B1547DB979DC9850B0C3B880C92443D9BDF4483235CE02B4732FCD0BF744B97FF166BAF6CD9768139E68562FA0D588EF82DC412C3C9D3372A5CF767D41FD3D20F5E4489DAF39EF2C2099F9E397E2E221ED9EE8CFCA5EAEE1E4756E3B";
        $token=$this->curl_post(self::BASEURL."login/updatePwd",$data,$header);
        var_dump($token);die;
    }
   /**
    * post 提交
    */
   public function curl_post($url,$post_data,$header=""){
       //初始化
       $curl = curl_init();
       //设置抓取的url
       curl_setopt($curl, CURLOPT_URL, $url);
       //设置头文件的信息作为数据流输出
       curl_setopt($curl, CURLOPT_HEADER, 1);
       //设置获取的信息以文件流的形式返回，而不是直接输出。
       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
       $headers=array(
           "SDB-Authorization"=>$header
       );
       curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
       //设置post方式提交
       curl_setopt($curl, CURLOPT_POST, 1);
       //设置post数据
       curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
       //执行命令
       $data = curl_exec($curl);
       //关闭URL请求
       curl_close($curl);
       //显示获得的数据
       return $data;
   }
}